home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / Events.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  8.2 KB  |  280 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        Events.mod
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$IF UNDEFINED OLDROUTINENAMES*)
  21. (*$SET OLDROUTINENAMES FALSE*)
  22. (*$END*)
  23. (*$TAGS-*)
  24. (*$CALLING PASCAL*)
  25. MODULE Events;
  26.  
  27. IMPORT SYSTEM, Types, Quickdraw, OSUtils;
  28.  
  29. (* $PUSH*)
  30. (* $ALIGN MAC68K*)
  31. (* $LibExport+*)
  32.     
  33. TYPE
  34.     MacOSEventKind* = Types.UInt16;
  35.  
  36.  
  37. CONST
  38.     nullEvent*                    = 0;
  39.     mouseDown*                    = 1;
  40.     mouseUp*                        = 2;
  41.     keyDown*                        = 3;
  42.     keyUp*                        = 4;
  43.     autoKey*                        = 5;
  44.     updateEvt*                    = 6;
  45.     diskEvt*                        = 7;
  46.     activateEvt*                    = 8;
  47.     osEvt*                        = 15;
  48.  
  49.     
  50. TYPE
  51.     MacOSEventMask* = Types.UInt16;
  52.  
  53.  
  54. CONST
  55.     mDownMask*                    = $0002;                        (* mouse button pressed *)
  56.     mUpMask*                        = $0004;                        (* mouse button released *)
  57.     keyDownMask*                    = $0008;                        (* key pressed *)
  58.     keyUpMask*                    = $0010;                        (* key released *)
  59.     autoKeyMask*                    = $0020;                        (* key repeatedly held down *)
  60.     updateMask*                    = $0040;                        (* window needs updating *)
  61.     diskMask*                    = $0080;                        (* disk inserted *)
  62.     activMask*                    = $0100;                        (* activate/deactivate window *)
  63.     highLevelEventMask*            = $0400;                        (* high-level events (includes AppleEvents) *)
  64.     osMask*                        = $8000;                        (* operating system events (suspend, resume) *)
  65.     everyEvent*                    = $FFFF;                        (* all of the above *)
  66.  
  67. (* event message equates *)
  68.     charCodeMask*                = $000000FF;
  69.     keyCodeMask*                    = $0000FF00;
  70.     adbAddrMask*                    = $00FF0000;
  71.     osEvtMessageMask*            = $FF000000;
  72. (* OS event messages.  Event (sub)code is in the high byte of the message field. *)
  73.     mouseMovedMessage*            = $00FA;
  74.     suspendResumeMessage*        = $0001;
  75.     resumeFlag*                    = 1;                            (* Bit 0 of message indicates resume vs suspend *)
  76.     convertClipboardFlag*        = 2;                            (* Bit 1 in resume message indicates clipboard change *)
  77.  
  78.     
  79. TYPE
  80.     MacOSEventModifiers* = Types.UInt16;
  81.  
  82.  
  83. CONST
  84. (* modifiers *)
  85.     activeFlag*                    = $0001;                        (* Bit 0 of modifiers for activateEvt and mouseDown events *)
  86.     btnState*                    = $0080;                        (* Bit 7 of low byte is mouse button state *)
  87.     cmdKey*                        = $0100;                        (* Bit 0 of high byte *)
  88.     shiftKey*                    = $0200;                        (* Bit 1 of high byte *)
  89.     alphaLock*                    = $0400;                        (* Bit 2 of high byte *)
  90.     optionKey*                    = $0800;                        (* Bit 3 of high byte *)
  91.     controlKey*                    = $1000;                        (* Bit 4 of high byte *)
  92.     rightShiftKey*                = $2000;                        (* Bit 5 of high byte *)
  93.     rightOptionKey*                = $4000;                        (* Bit 6 of high byte *)
  94.     rightControlKey*                = $8000;                        (* Bit 7 of high byte *)
  95.  
  96.  
  97. TYPE
  98.     EventRecord* = RECORD
  99.         what*:                    MacOSEventKind;
  100.         message*:                Types.UInt32;
  101.         when*:                    Types.UInt32;
  102.         where*:                    Types.Point;
  103.         modifiers*:                MacOSEventModifiers;
  104.     END;
  105.  
  106.     KeyMap* = ARRAY 4 OF LONGINT (*ΔΔ PACKED ARRAY [0..127] OF BOOLEAN*);
  107.  
  108.     EvQEl* = RECORD
  109.         qLink*:                    OSUtils.QElemPtr;
  110.         qType*:                    INTEGER;
  111.         evtQWhat*:                MacOSEventKind;                            (* this part is identical to the EventRecord as... *)
  112.         evtQMessage*:            Types.UInt32;                                    (* defined above *)
  113.         evtQWhen*:                Types.UInt32;
  114.         evtQWhere*:                Types.Point;
  115.         evtQModifiers*:            MacOSEventModifiers;
  116.     END;
  117.  
  118.     EvQElPtr* = POINTER TO EvQEl;
  119.  
  120.     GetNextEventFilterProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (VAR theEvent: EventRecord; VAR result: BOOLEAN);
  121.     GetNextEventFilterUPP* = Types.UniversalProcPtr;
  122.  
  123. CONST
  124.     uppGetNextEventFilterProcInfo* = $000000BF; (* SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc ) *)
  125.  
  126. PROCEDURE NewGetNextEventFilterProc*(userRoutine: GetNextEventFilterProcPtr): GetNextEventFilterUPP;
  127.     (*$IF NOT GENERATINGCFM *)
  128.     INLINE PASCAL $2E9F;
  129.     (*$END*)
  130.  
  131. PROCEDURE CallGetNextEventFilterProc*(VAR theEvent: EventRecord; VAR result: BOOLEAN; userRoutine: GetNextEventFilterUPP);
  132.     (*$IF NOT GENERATINGCFM*)
  133.     INLINE PASCAL ; (*••*)
  134.     (*To be implemented*:  Glue to move parameters according to special case conventions.*)
  135.     (*$END*)
  136.     
  137. TYPE
  138.     GNEFilterUPP* = GetNextEventFilterUPP;
  139.  
  140.     FKEYProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE ;
  141.     FKEYUPP* = Types.UniversalProcPtr;
  142.  
  143. CONST
  144.     uppFKEYProcInfo* = $00000000; (* PROCEDURE ; *)
  145.  
  146. PROCEDURE NewFKEYProc*(userRoutine: FKEYProcPtr): FKEYUPP;
  147.     (*$IF NOT GENERATINGCFM *)
  148.     INLINE PASCAL $2E9F;
  149.     (*$END*)
  150.  
  151. PROCEDURE CallFKEYProc*(userRoutine: FKEYUPP);
  152.     (*$IF NOT GENERATINGCFM*)
  153.     INLINE PASCAL $205F, $4E90;
  154.     (*$END*)
  155. PROCEDURE GetCaretTime*(): Types.UInt32;
  156.     (*$IF NOT CFMSYSTEMCALLS*)
  157.     INLINE PASCAL $2EB8, $02F4;            (* MOVE.l $02F4,(SP) *)
  158.     (*$END*)
  159.  
  160. PROCEDURE SetEventMask*(value: MacOSEventMask );
  161.     (*$IF NOT CFMSYSTEMCALLS*)
  162.     INLINE PASCAL $31DF, $0144;            (* MOVE.w (SP)+,$0144 *)
  163.     (*$END*)
  164.  
  165. PROCEDURE GetEventMask*(): MacOSEventMask;
  166.     (*$IF NOT CFMSYSTEMCALLS*)
  167.     INLINE PASCAL $3EB8, $0144;            (* MOVE.w $0144,(SP) *)
  168.     (*$END*)
  169.  
  170. PROCEDURE GetEvQHdr*(): OSUtils.QHdrPtr;
  171.     (*$IF NOT GENERATINGCFM*)
  172.     INLINE PASCAL $2EBC, $0000, $014A;
  173.     (*$END*)
  174. (* InterfaceLib exports GetEvQHdr, so make GetEventQueue map to that *)
  175. PROCEDURE GetDblTime*(): Types.UInt32;
  176.     (*$IF NOT CFMSYSTEMCALLS*)
  177.     INLINE PASCAL $2EB8, $02F0;            (* MOVE.l $02F0,(SP) *)
  178.     (*$END*)
  179.  
  180. (* InterfaceLib exports GetDblTime, so make GetDoubleClickTime map to that *)
  181. PROCEDURE GetNextEvent*(eventMask: MacOSEventMask; VAR theEvent: EventRecord): BOOLEAN;
  182.     (*$IF NOT GENERATINGCFM*)
  183.     INLINE PASCAL $A970;
  184.     (*$END*)
  185. PROCEDURE WaitNextEvent*(eventMask: MacOSEventMask; VAR theEvent: EventRecord; sleep: Types.UInt32; mouseRgn: Quickdraw.RgnHandle): BOOLEAN;
  186.     (*$IF NOT GENERATINGCFM*)
  187.     INLINE PASCAL $A860;
  188.     (*$END*)
  189. PROCEDURE EventAvail*(eventMask: MacOSEventMask; VAR theEvent: EventRecord): BOOLEAN;
  190.     (*$IF NOT GENERATINGCFM*)
  191.     INLINE PASCAL $A971;
  192.     (*$END*)
  193. PROCEDURE GetMouse*(VAR mouseLoc: Types.Point);
  194.     (*$IF NOT GENERATINGCFM*)
  195.     INLINE PASCAL $A972;
  196.     (*$END*)
  197. PROCEDURE Button*(): BOOLEAN;
  198.     (*$IF NOT GENERATINGCFM*)
  199.     INLINE PASCAL $A974;
  200.     (*$END*)
  201. PROCEDURE StillDown*(): BOOLEAN;
  202.     (*$IF NOT GENERATINGCFM*)
  203.     INLINE PASCAL $A973;
  204.     (*$END*)
  205. PROCEDURE WaitMouseUp*(): BOOLEAN;
  206.     (*$IF NOT GENERATINGCFM*)
  207.     INLINE PASCAL $A977;
  208.     (*$END*)
  209. PROCEDURE GetKeys*(theKeys: KeyMap);
  210.     (*$IF NOT GENERATINGCFM*)
  211.     INLINE PASCAL $A976;
  212.     (*$END*)
  213. PROCEDURE KeyTranslate*(transData: (*ΔΔUNIVΔΔ*) Types.Ptr; keycode: Types.UInt16; VAR state: Types.UInt32): Types.UInt32;
  214.     (*$IF NOT GENERATINGCFM*)
  215.     INLINE PASCAL $A9C3;
  216.     (*$END*)
  217. PROCEDURE TickCount*(): Types.UInt32;
  218.     (*$IF NOT GENERATINGCFM*)
  219.     INLINE PASCAL $A975;
  220.     (*$END*)
  221. PROCEDURE PostEvent*(eventNum: MacOSEventKind; eventMsg: Types.UInt32): Types.OSErr;
  222.     (*$IF NOT GENERATINGCFM*)
  223.     INLINE PASCAL $201F, $305F, $A02F, $3E80;
  224.     (*$END*)
  225. PROCEDURE PPostEvent*(eventCode: MacOSEventKind; eventMsg: Types.UInt32; VAR qEl: EvQElPtr): Types.OSErr;
  226.     (*$IF NOT GENERATINGCFM*)
  227.     INLINE PASCAL $225F, $201F, $305F, $A12F, $2288, $3E80;
  228.     (*$END*)
  229. PROCEDURE OSEventAvail*(mask: MacOSEventMask; VAR theEvent: EventRecord): BOOLEAN;
  230.     (*$IF NOT GENERATINGCFM*)
  231.     INLINE PASCAL $205F, $301F, $A030, $5240, $1E80;
  232.     (*$END*)
  233. PROCEDURE GetOSEvent*(mask: MacOSEventMask; VAR theEvent: EventRecord): BOOLEAN;
  234.     (*$IF NOT GENERATINGCFM*)
  235.     INLINE PASCAL $205F, $301F, $A031, $5240, $1E80;
  236.     (*$END*)
  237. PROCEDURE FlushEvents*(whichMask: MacOSEventMask; stopMask: MacOSEventMask);
  238.     (*$IF NOT GENERATINGCFM*)
  239.     INLINE PASCAL $201F, $A032;
  240.     (*$END*)
  241. PROCEDURE SystemClick*((*CONST*)VAR theEvent: EventRecord; theWindow: Quickdraw.WindowPtr);
  242.     (*$IF NOT GENERATINGCFM*)
  243.     INLINE PASCAL $A9B3;
  244.     (*$END*)
  245. PROCEDURE SystemTask*;
  246.     (*$IF NOT GENERATINGCFM*)
  247.     INLINE PASCAL $A9B4;
  248.     (*$END*)
  249. PROCEDURE SystemEvent*((*CONST*)VAR theEvent: EventRecord): BOOLEAN;
  250.     (*$IF NOT GENERATINGCFM*)
  251.     INLINE PASCAL $A9B2;
  252.     (*$END*)
  253. (*$IF OLDROUTINENAMES *)
  254.  
  255. CONST
  256.     networkEvt*                    = 10;
  257.     driverEvt*                    = 11;
  258.     app1Evt*                        = 12;
  259.     app2Evt*                        = 13;
  260.     app3Evt*                        = 14;
  261.     app4Evt*                        = 15;
  262.     networkMask*                    = $0400;
  263.     driverMask*                    = $0800;
  264.     app1Mask*                    = $1000;
  265.     app2Mask*                    = $2000;
  266.     app3Mask*                    = $4000;
  267.     app4Mask*                    = $8000;
  268.  
  269.  
  270. PROCEDURE KeyTrans*(transData: (*ΔΔUNIVΔΔ*) Types.Ptr; keycode: Types.UInt16; VAR state: Types.UInt32): Types.UInt32;
  271.     (*$IF NOT GENERATINGCFM*)
  272.     INLINE PASCAL $A9C3;
  273.     (*$END*)
  274. (*$END*)
  275.  
  276. (* $ALIGN RESET*)
  277. (* $POP*)
  278.  
  279.  END Events.
  280.